/*
 * Copyright(c) 2020-2100 万达信息股份有限公司 版权所有
 * WONDERS INFORMATION CO., LTD. ALL RIGHTS RESERVED.
 */

package com.wondersgroup.feignclients;

import com.wondersgroup.entity.Product;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 调用商品服务的openfeign组件
 * 所有方法参数上面都要加上注解：传递普通参数时用注解@RequestParam，传递对象参数时用注解@RequestBody
 *
 * @author: huym
 * @version: 1.0
 * @date: 2020/11/19
 */
@FeignClient(value = "product",fallback = ProductFallBack.class) //用来标识担当起接口是一个feign组件，value是服务id
public interface ProductClient {

    @GetMapping("/product/showMsg")
    String showMsg();

    @GetMapping("/product/findOne")
    Map<String,Object> findOne(@RequestParam(name = "productId") String productId);

    @PostMapping("/product/save")
    Map<String, Object> save(@RequestParam("name") String name);  // 传递普通参数时，必须要有注解@RequestParam

    @PostMapping("/product/saveProduct")
    Map<String, Object> saveProduct(@RequestBody Product product); // 传递对象参数时，必须要有注解@RequestBody

    @RequestMapping("/product/complex")
    Map<String,Object> complex(@RequestBody Product product, @RequestParam String name);
}
